package xyz.archknight.app.loginput.dictionary.gen.dao

import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction

/**
 * 内存词库控制
 *
 * @author midnite
 * create at 2020-06-18 6:00 上午
 */
object DBUtils {
    init {
        Database.connect("jdbc:h2:mem:main;DB_CLOSE_DELAY=-1;", driver = "org.h2.Driver")
    }

    fun updateTables() {
        transaction {
            SchemaUtils.createMissingTablesAndColumns(Words, Caches)
        }
    }

    fun resetTables() {
        transaction {
            SchemaUtils.drop(Words, Caches)
            SchemaUtils.createMissingTablesAndColumns(Words, Caches)
        }
    }
}